﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<div class="modal-dialog ms-modal-dialog" style="margin-top: 100px;">
  <div class="modal-content">

    <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal">
        <span aria-hidden="true">&times;</span><span class="sr-only">Close</span>
      </button>
      <h4 class="modal-title">Session&nbsp;-&nbsp;Add Delegate</h4>
    </div>

    <form class="form-horizontal ms-form" role="form" action="${ctx.host}/sessions/${session.id}/schedulings/relation/delegates" method="POST" data-validate="true">

      <input type="hidden" name="subSession" value="${subSession}"/>
      <input type="hidden" name="subGroup" value="${subGroup}"/>
      <input type="hidden" name="seat" value="${seat}"/>
      
      <div class="modal-body">
        
        <div class="form-group x-form-group discount-type">
          <label class="col-xs-4 control-label">Delegate</label>
          <div class="col-xs-6 pull-left">
            <select name="delegateId" data-validate="required" class="select2 form-control">
              <option></option>
              <c:forEach var="delegate" items="${delegates}">
                <option value="${delegate.id}" ${delegate.knowWell ? 'disabled="disabled"' : ''}>${delegate.name}</option>
              </c:forEach>
            </select>
          </div>
        </div>
        
      </div>

      <div class="modal-footer">
        <button type="submit" class="btn btn-success btn-shadow btn-shadow-success x-btn">Submit</button>
        <button type="button" class="btn btn-default btn-shadow btn-shadow-default x-btn" data-dismiss="modal">Cancel</button>
      </div>
      
    </form>
  </div>
</div>
<script type="text/javascript">
  $(function() {
    
    $('.select2').select2({
      placeholder : 'Select Delegate',
      minimumResultsForSearch : -1,
      allowClear : true
    });

    $(document).find('form[data-validate="true"]').bt_validate() //bind validate
    
    var $form = $(document).find("form") //bind shiftform
    $form.shiftform({
      beforeSubmit : function(el) {
        $form.trigger("validate.ajax.submit");
        return $.bt_validate.result[$.bt_validate.form_id]
      }
    })
    
  })
</script>
